package com.feituan.manager.controller;

import com.feituan.core.service.IAdviceBizService;
import com.feituan.core.pojo.request.AdvicePageReq;
import com.feituan.core.pojo.entity.Advice;
import com.feituan.core.pojo.response.Response;
import com.feituan.core.pojo.response.page.PageData;
import com.feituan.core.service.IAdviceBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "/advice")
@Api(tags = "留言板管理")
public class AdviceController {

    @Autowired
    private IAdviceBizService adviceBizService;


    @PostMapping("/list_page")
    @ApiOperation("")
    public Response<PageData<Advice>> listPage(@Valid AdvicePageReq request) {
        return Response.success(adviceBizService.queryPage(request));
    }

    @PostMapping("/save")
    @ApiOperation("新增留言板管理")
    public Response<Boolean> saveAdvice(Advice advice) {
        return Response.success(adviceBizService.saveAdvice(advice) > 0);
    }


    @PostMapping("/updateStatusById")
    @ApiOperation("修改留言板已读未读状态")
    public Response<Boolean> updateStatusById(Integer id) {
        return Response.success(adviceBizService.updateAdvice(id) == 0);
    }
}
